package cn.springmvc.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.springmvc.common.datasource.DataSourceEnum;
import cn.springmvc.common.datasource.DynamicDataSourceHolder;
import cn.springmvc.entity.OpenSurvey;
import cn.springmvc.repository.OpenSurveyRepository;

/**
 * @author Vincent.wang
 *
 */
@Repository
public class OpenSurveyDaoService {

    @Autowired
    protected OpenSurveyRepository openSurveyRepository;

    public OpenSurvey findOpenSurveyById(String id) {
        DynamicDataSourceHolder.setDataSourceKey(DataSourceEnum.SLAVE.getKey());
        return openSurveyRepository.findOpenSurveyById(id);
    }

    public List<OpenSurvey> findOpenSurveyAll() {
        DynamicDataSourceHolder.setDataSourceKey(DataSourceEnum.SLAVE.getKey());
        return openSurveyRepository.findOpenSurveyAll();
    }
}
